{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from sklearn.preprocessing import PolynomialFeatures"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0, 1],\n",
       "       [2, 3],\n",
       "       [4, 5]])"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X = np.arange(6).reshape(3,2)\n",
    "X"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "PolynomialFeatures(degree=2, include_bias=True, interaction_only=False)\n",
      "[[  1.   0.   1.   0.   0.   1.]\n",
      " [  1.   2.   3.   4.   6.   9.]\n",
      " [  1.   4.   5.  16.  20.  25.]]\n"
     ]
    }
   ],
   "source": [
    "poly1 = PolynomialFeatures(2)\n",
    "poly1.fit(X)\n",
    "print poly1\n",
    "print poly1.transform(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "PolynomialFeatures(degree=2, include_bias=True, interaction_only=True)\n",
      "[[  1.   0.   1.   0.]\n",
      " [  1.   2.   3.   6.]\n",
      " [  1.   4.   5.  20.]]\n"
     ]
    }
   ],
   "source": [
    "poly2 = PolynomialFeatures(interaction_only=True)\n",
    "poly2.fit(X)\n",
    "print poly2\n",
    "print poly2.transform(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "PolynomialFeatures(degree=2, include_bias=False, interaction_only=False)\n",
      "[[  0.   1.   0.   0.   1.]\n",
      " [  2.   3.   4.   6.   9.]\n",
      " [  4.   5.  16.  20.  25.]]\n"
     ]
    }
   ],
   "source": [
    "poly3 = PolynomialFeatures(include_bias=False)\n",
    "poly3.fit(X)\n",
    "print poly3\n",
    "print poly3.transform(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
